 {% extends 'base.html' %} 
 {% block title %}{{ category_name }}{% endblock %}
 {% block body_block %}
<div class="hero-unit">
	<h1>{{ category_name }}</h1>

	{% if category %}
	<p>
	    <b id="like_count">{{category.likes }}</b> people like this category

	    {% if user.is_authenticated %}
	        <button id="likes" data-catid="{{ category.id }}" class="btn btn-mini btn-primary" type="button">Like</button>
	    {% endif %}
	</p>
   <br/>
    <div id="pages">
	    {% if pages %}
	    <ul>
		{% for page in pages %}
		<li><a href="{% url 'goto' %}?page_id={{page.id}}">{{ page.title }}</a>
		{% if page.views > 1 %}
		   ({{ page.views}} views)
		{%elif page.views == 1 %}
		    ({{ page.views}} views)
		{% endif %}
		</li>
		{% endfor %}
	    </ul>
	    {% else %}
	      <strong>No pages currently in category.</strong>
	    {% endif %} 
	</div>

        {% if user.is_authenticated %}
        <a href="/tango/category/{{ category.slug }}/add_page/">Add a Page</a><br /> 
        {% endif %}
</div>

<div class="hero-unit">
	<div class="cantainer-fluid">
		<p>Search for a page.</p>
		<form class="span8 form-search" id="search_form" method="post" action="/tango/category/{{ category.slug }}/">
			{%csrf_token %}
			<input type="text" class="input-long search-query" name="query" value="{{ category_name }}" id="query" />
			<button type="submit" class="btn btn-success" name="submit" value="Search">Search</button>
		</form>
	</div>
	<div class="container-fluid">
		{% if result_list %}
		<!-- Display search results in an ordered list -->
		<ol>
			{% for result in result_list %}
			<li>
				{% if user.is_authenticated %}
				<button data-catid="{{category.id}}" data-title="{{result.title}}" data-url="{{result.link }}" class="tango-add btn btn-mini btn-info" type="button">Add</button>
				{% endif %}
				<strong><a href="{{result.link }}">{{result.title}}</a></strong><br/>
				<p>{{result.summary}}</p>
			</li>
			{% endfor %}
		</ol>
		{% else %}
		 <br/>
		 <p>No results found</p>
		 {% endif %}
		</div> 

    {% else %}
        The specified category {{ category_name }} does not exitst 
    {% endif %}
</div>

 {% endblock %}